#include <iostream>
#include <vector>

void Test1()
{
  int num = 1;
  int other = 100;
  int *const pa1 = &num;
  int const *pa2 = &num;
  *pa1 = 2;
  //const出现在*右边，表示指针无法修改
  //pa1 = &other;
  //const出现在*左边，表示指针所指内容无法修改
  //*pa2 = 2;
  pa2 = &other;

}

void Test2()
{
  char buffer[] = "hello world";
  const char* p1 = "hello world";
  std::cout << p1 << std::endl;
  p1 = buffer;
  std::cout << p1 << std::endl;
  //p1[0] = 'k';
}

void Test3()
{
  std::vector<int> myv;
  myv.push_back(1);
  myv.push_back(2);
  myv.push_back(3);

  std::vector<int>::const_iterator cit = myv.cbegin();
  while(cit != myv.cend()){
    std::cout << *cit << " ";
    //*cit = 10;
    cit++;
  }
  std::cout << std::endl;

  std::vector<int>::iterator it = myv.begin();
  while(it != myv.end()){
    *it = 10;
    std::cout << *it << " ";
    it++;
  }
  std::cout << std::endl;
}

int main()
{
  //Test2();
  Test3();
  return 0;
}
